
package app.Persistencia;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql. Statement;

import app.Modelo.Empleado;
import java.sql.SQLException;


public class Conexion {
    // Mtodo Conectar
    public Connection conectar()
    {
        Connection con = null;
        try{
         con= DriverManager.getConnection("jdbc:odbc: ConexionSQL");
        Statement sentencia = con.createStatement();

        }catch( Exception e){
         System.out.println("Error:" + e.getMessage());
        }

        return con;
    }
 
     public void  GuaradarEmpleado(Empleado e) throws SQLException
    {
        //ResultSet rs= sentencia.executeQuery("select * from usuario");
        
        Connection con= null;
        Statement smt;
        ResultSet res;
        try{
        String consulta= "INSERT INTO Empleado VALUES( +"+ 0
                                                        + e.getNombre()+ ","
                                                        + e.getApe_Paterno()+ ","
                                                        + e.getApe_Materno()+ ","
                                                        + 0
                                                        + e.getNss() + ","
                                                        + e.getCalle()+ ","
                                                        + e.getColonia() + ","
                                                        + e.getNum_exterior()+ ","
                                                        + e.getNum_interior()+ ","
                                                        + e.getTel()+ ","
                                                        + e.getFe_ingreso()+ "')";
        
            smt = con.createStatement();
            smt.executeUpdate(consulta);
        }catch(Exception ex){
            System.out.println("Error desconocido:" + ex.getMessage());
        }
        }
}


